package com.jie.other.ui.list_choose_dialog

import androidx.compose.foundation.clickable
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier

@Composable
fun ListChooseListView(
    list : List<ListItemDTO>,
    itemClickListener : ((Int, ListItemDTO) -> Unit)? = null,
    scrollState : LazyListState = rememberLazyListState(),
    modifier: Modifier = Modifier,
) {
    LazyColumn(
        modifier,
        state = scrollState,
    ) {
        items(
            list,
            key = { task -> task.hashCode() }
        ) {
            ListChooseItemView(
                itemDTO = it,
                showBottomLine = list.indexOf(it) < list.size - 1,
                modifier = Modifier
                    .clickable {
                    itemClickListener?.invoke(list.indexOf(it), it)
                })
        }
    }
}